import Base from '../../base';
import {getDOMHeight, setMaxHeight} from '../../util';

export default class Table extends Base {
    setMaxHeight() {
        const theadHeight = getDOMHeight($('.ant-table-thead', this.dom));
        const pagerHeight = getDOMHeight($('.ant-table-pagination', this.dom));
        const tableHeight = this.maxHeight() - pagerHeight;
        const delta = $(this.dom).hasClass('ant-table-empty') ? 30 : 0;
        const totalHeight = tableHeight - delta;
        setMaxHeight($('.ant-table-body', this.dom), totalHeight);
        const bodyHeight = totalHeight - theadHeight;
        if (bodyHeight !== this.state.height) {
            this.setState({height: bodyHeight});
        }
    }
}
